﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace ConsoleNew
{
    /// <summary>
    /// override是重载(有的翻译为覆盖)，new是隐藏。override可以通过父类的引用调用子类的方法，new只能各自调用各自的方法。
    /// </summary>
    class Program
    {
        private delegate void Del(int i, int j);

        public void Add(int i, int j)
        {
            Console.WriteLine(i + j);
        }

        public void threadFuc1()
        {
            Console.WriteLine("线程1");
        }
        public void threadFuc2()
        {
            
            Console.WriteLine("线程2");
        }
        static void Main(string[] args)
        {
            string aa = null;
            if (aa == null || int.Parse(aa)>0)
            {
                Console.WriteLine("zhuanh2");
            }
            Program p = new Program();
            Thread t1 = new Thread(new ThreadStart(p.threadFuc1));
            Thread t2 = new Thread(new ThreadStart(p.threadFuc2));
            t1.Start();
            t2.Start();
            Del del = new Del(p.Add);
            del(1, 2);

            ArrayList list = new ArrayList();
            list.Add("Hello");
            list.Add("World");
            list.Add("!");
            Console.WriteLine("    Count:    {0}", list.Count);
            Console.WriteLine("    Capacity: {0}", list.Capacity);//默认为4
            Console.Write("    Values:");
            PrintValues(list);

            double d = Int32.MaxValue + 0.1314;
            int i1 = (int)d;
            Int16 i = 5;
            object a = i;
            Int32 b = Convert.ToInt32(a);
            Console.WriteLine(Int32.MaxValue + "-----" + d);
            #region   override是重载(有的翻译为覆盖)，new是隐藏。override可以通过父类的引用调用子类的方法，new只能各自调用各自的方法。
            A A1 = new B();
            A1.MethodA();
            A1.MethodB();
            B B1 = new B();
            B1.MethodA();
            B1.MethodB();
            B.MethodC();
            #endregion

            Console.ReadKey();
        }
        public static void PrintValues(IEnumerable myList)
        {
            foreach (Object obj in myList)
                Console.Write("   {0}", obj);
            Console.WriteLine();
            Console.ReadKey();
        }
    }
    public class A
    {
        public virtual void MethodA()
        {
            Console.WriteLine("A.MethodA");
        }

        public void MethodB()
        {
            Console.WriteLine("A.MethodB");
        }
    }

    public class B : A
    {
        public override void MethodA()
        {
            //  base.MethodA();
            Console.WriteLine("B.MethodA");
        }

        public new void MethodB()
        {
            Console.WriteLine("B.MethodB");
        }

        public static void MethodC()
        {
            Console.WriteLine("B.MethodC");
        }
    }

    public class TextChangeEventArgs : EventArgs
    {
        private string message;
        public TextChangeEventArgs(string message)
        {
            this.message = message;
        }
        public string Message
        {
            get { return message; }
        }
    }
}
